<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <link rel="stylesheet" href="css/style-user.css">
    <script src="layui/layui.js"></script>
</head>
<body>

<div id="loginForm" class="login-main">
    <header class="layui-elip">登录</header>
    <form class="layui-form">
        <div class="layui-input-inline">
            <input type="text" name="account"  lay-verify="required" placeholder="用户名" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input type="password" name="password"  lay-verify="required" placeholder="密码" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline">
            <div class="layui-col-xs7">
                <input type="password" name="validatecode"  lay-verify="required" placeholder="验证码" autocomplete="off"
                       class="layui-input">
            </div>
            <div class=" layui-col-xs-offset1 layui-col-xs4">
                <img src="dangdanglayui/validatecode/getCode.do">
            </div>
        </div>
        <div class="layui-input-inline login-btn">
            <button lay-submit lay-filter="login" class="layui-btn">登录</button>
        </div>
        <hr/>
        <p><a href="register.html" class="fl">立即注册</a><a href="findPwd.html" class="fr">忘记密码？</a></p>
    </form>
</div>

<script>
    layui.use(['form'],function () {
        var form = layui.form;
        var $ = layui.$;
        console.log("aaaaa");
        form.on('submit(login)',function () {
            console.log("bbbbb");
            $.ajax({
                url:'manager/login2.do',
                data:$("#loginForm").serialize(),
                success:function (result) {
                    var flag = result.login2;
                    if(flag){
                        location.href="${pageContext.request.contextPath}/index.html";
                    }
                }
            })
            return false;//阻止表单提交   否则表单会自动刷新提交
    })
</script>

</body>
</html>